﻿function ConfirmDel(delObject){
    if(confirm('确定要删除[' + delObject +']吗?'))
        return true;    
    else
        return false;        
}
function GetDialogReturnValue(url, width, height, feature) {

    if (feature == "FullScreen") {
        feature = "dialogWidth:" + screen.availWidth + "px;dialogHeight:" + screen.availHeight + "px;status:Modal;help:no";
    }
    else {
        feature = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;";
    }
    var u = url.toString();
    if (u.indexOf("?") > -1) {
        url = url + "&" + Math.random();
    }
    else {
        url = url + "?" + Math.random();
    }
    var rtn = window.showModalDialog(url, window, feature);
    return rtn;
}

function ShowDialog(url, width, height, feature) {

    if (feature == "FullScreen") {
        feature = "dialogWidth:" + screen.availWidth + "px;dialogHeight:" + screen.availHeight + "px;status:Modal;help:no;scroll:no";
    }
    else {
        feature = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;" + feature;
    }

    var u = url.toString();
    if (u.indexOf("?") > -1) {
        url = url + "&" + Math.random();
    }
    else {
        url = url + "?" + Math.random();
    }

    var rtn = window.showModalDialog(url, window, feature);    
    if (rtn == "true" || rtn == true) {
        var hidIsRebind = document.getElementById("hidIsRebind");
        if (hidIsRebind != null) {
            hidIsRebind.value = "true";
        }        
        var f =$("form[0]");
        if (f != null) {            
            f.submit();
        }
        return true;       
    }
    else if (rtn != null && rtn != "false" && rtn != "") {
        try {
            document.URL = rtn;
        }
        catch (e) {
        }
    }
    return false;
}


function WinOpen(url, width, height, formName) {
    var u = url.toString();
    if (u.indexOf("?") > -1) {
        url = url + "&" + Math.random();
    }
    else {
        url = url + "?" + Math.random();
    }
    var openobj = window;
    if (typeof (window.dialogArguments) == "object") {
        openobj = window.dialogArguments;
    }
    if (width == null || width == "" || height == null || height == "") {
        openobj.open(url);
    }
    else {
        openobj.open(url, formName, "width=" + width + ",height=" + height + ",top=0,left=0,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes");
    }
}

function closeWindow() {
    window.open('', '_parent', '');
    this.window.close();
}

$(document).ready(function () {
    $(".dataGrid tbody tr:even").addClass("trEven");
    $(".dataGrid tbody tr:odd").addClass("trOdd");
    initToggle();
    initDatagrid();
    buttonHover();
    closeNavHover();
})

////////////////////////////////////////////////////////
// 函数名称：buttonHover
// 功能说明：控制鼠标经过按钮时效果
///////////////////////////////////////////////////////	
function buttonHover() {
    $('.inputbtn').hover(function () {
        $(this)
	.addClass('inputbtn2')
	.siblings().removeClass('inputbtn2')
	.end()
    });
}

function closeNavHover() {
    $('.closeNav').hover(function () {
        $(this)
	.addClass('closeNavHover')
	.siblings().removeClass('closeNavHover')
	.end()
    });
}

////////////////////////////////////////////////////////
// 函数名称：initDatagrid
// 功能说明：datagrid选中行变色与鼠标经过行变色
///////////////////////////////////////////////////////
function initDatagrid() {
    $('.Grid :radio:checked').parents('tr').addClass('selected');
    $('.Grid tbody>tr').hover(function () {
        $(this)
		  .addClass('selected')
		  .siblings().removeClass('selected')
		  .end()
	  .find(':radio').attr('checked', true)
    });
}
////////////////////////////////////////////////////////
// 函数名称：initToggle
// 功能说明：折叠表单
///////////////////////////////////////////////////////
function initToggle() {
    $(".zdtitle").click(function () {
        var t = $(this).next(".inputform");
        t.toggle();
        if (t.get(0).style.display == "none") {
            $(this).get(0).className = "zdtitleclose";
        } else {
            $(this).get(0).className = "zdtitle";
        }
    })
    $(".zdtitleclose").click(function () {
        var t = $(this).next(".inputform");
        t.toggle();
        if (t.get(0).style.display == "none") {
            $(this).get(0).className = "zdtitleclose";
        } else {
            $(this).get(0).className = "zdtitle";
        }
    })
}

////////////////////////////////////////////////////////	
// 函数名称：mulOperate
// 功能说明：多项操作使用下拉方式
///////////////////////////////////////////////////////
function mulOperate() {
    $(".muloperate,.muloperate ul").hover(function () {
        $(".muloperate ul").addClass("hover");
    }, function () {
        $(".muloperate ul").removeClass("hover");
    });
    $(".muloperate").click(function () {
        $(".muloperate ul").addClass("hover");
    }, function () {
        $(".muloperate ul").removeClass("hover");
    });
}

////////////////////////////////////////////////////////
// 函数名称：changit
// 功能说明：树菜单的展示/收缩
///////////////////////////////////////////////////////
function changit() {
    if (parent.forum.cols != "0,*") {
        parent.forum.cols = "0,*";
        LR.src = "images/hide1.gif";
    }
    else {
        parent.forum.cols = "180,*";
        LR.src = "images/hide.gif";
    } 
}

////////////////////////////////////////////////////////
// 函数名称：SetWinHeight
// 功能说明：iframe的高度
///////////////////////////////////////////////////////
function SetWinHeight(obj) {
    var win = obj;
    var i, j, k,l;
    i = 0;j = 0;k = 0;l = 0;
    if (document.getElementById) {
        if (win && !window.opera) {
            if (win.contentDocument && win.contentDocument.body.offsetHeight)
                i = win.contentDocument.body.offsetHeight + 20;
            if (win.Document && win.Document.body.scrollHeight)
                j = win.Document.body.scrollHeight + 20;
            if(win.ownerDocument &&  win.ownerDocument.body.offsetHeight )
                k = win.ownerDocument.body.offsetHeight + 20;

            if (win.document && win.document.parentWindow && win.document.parentWindow.top)
                l = win.document.parentWindow.top.document.body.scrollHeight - 145;
            //l = win.document.parentWindow.screen.availHeight - 240;  

            win.height = Math.max(i,j,k,l);
        }
    }
}

hide = true;
function showHideDept(rootPath) {
    var icon = document.getElementById("icon");
    var leftMenu = document.getElementById("leftMenu");
    if (hide) {
        parent.forum.cols = "10,*";
        leftMenu.style.paddingLeft = 10;
        icon.src = rootPath + "images/ico_ex_open.gif";
        hide = false;
    } else {
        parent.forum.cols = "182,*";
        leftMenu.style.paddingLeft = 0;
        icon.src = rootPath + "images/ico_ex_close.gif";
        hide = true;
    }
}